<?php
if(isset($javascript)):
// load script in <head> section
$javascript->link('scriptaculous/lib/prototype', false);
endif;
?>
<script>
function checkAll(all,user){
    a=user.split(',');
    for(i=0;i<a.length;i++){
        $('UserUser'+a[i]).checked=all.checked;
    }
}
</script>
<div class="groups form">
<h2><?php __('Groups')?></h2>
<?php echo $form->create('Group',array('url'=>array('committee'=>$dcommittee['Committee']['short_name'],'action'=>'add')));?>
    <fieldset>
        <legend><?php __('Add Group');?></legend>
        <div class="fieldset-inside">
    <?php
        echo $form->input('name', array('error'=>__('This field cannot be left blank',true)));
        echo $form->label(__('User',true));
        $user_ids=implode(',',array_keys($users));
        echo $html->div('input checkbox',
            $form->checkbox('Select All',array('checked'=>false,'onClick'=>'checkAll(this,"'.$user_ids.'")')).$form->label(__('Select All',true))
        );
        echo $form->input('User',array('label'=>false,'multiple'=>'checkbox'));
    ?>
    </fieldset>
<?php echo $form->button(__('Save', true),array('type'=>'submit'));?>&nbsp;
<?php echo $form->button(__('Cancel', true), array('type'=>'button', 'onclick'=>'history.go(-1)'));?>
<?php echo $form->end();?>
</div>

